{% extends "base.html" %}

<!--
{% block navbar_right %}
    <li>
        <a href="/accounts/login/">Login</a>
    </li>
    <li>
        <a href="/accounts/register/">Register</a>
    </li>
{% endblock %}
-->

{% block content %}
    

    <!--{% if messages %}
    <ul class="messages">
        {% for message in messages %}
        <li{% if message.tags %} class="{{ message.tags }}"{% endif %}>{{ message }}</li>
        {% endfor %}
    </ul>
    {% endif %}-->


    <div class="page-header">
        <h3>Top achievementy</h3>
    </div>

    
        <ul class="nav nav-tabs">
            <li class="active"><a href="#tab1" data-toggle="tab">Spoločné</a></li>
            <li><a href="#tab2" data-toggle="tab">Používateľské</a></li>
        </ul>
        <div class="tab-content">
            <div class="tab-pane active" id="tab1">
                {% if top_achievements_list %}
                    <table class='table table-striped table-bordered'>
                        <thead>
                            <tr>
                                <th>Achievement</th>
                                <th>Odmena</th>
                                <th>Splnené</th>
                            </tr>
                        </thead>
                        <tbody>
                        {% for achi in top_achievements_list %}
                            <tr>
                                <td><a href="{% url show_one_achievement achievement_id=achi.uuid %}">{{achi.name}}</a></td>
                                
                                {% if achi.points == 0 %}
                                    <td><span class="badge">Bez odmeny</span></td>
                                {% else %}
                                    <td><span class="badge badge-info">{{ achi.points }}</span>
					{% if achi.points == 1 %}bod
					{% elif achi.points >= 2 and achi.points <= 4 %}body
					{% else %}bodov
					{% endif %}
				     </td>
                                {% endif %}
                                
                                <td><span class="badge">{{ achi.count }}</span> krát</td>
                            </tr>
                        {% endfor %}
                        <tbody>
                    </table>
                {% else %}
                    <p> Nie sú dostupné žiadne obľúbené spoločné achievementy. </p>
                {% endif %}
            </div>
            <div class="tab-pane" id="tab2">
                {% if top_achievements_list_user %}
                    <table class='table table-striped table-bordered'>
                        <thead>
                            <tr>
                                <th>Achievement</th>
                                <th>Odmena</th>
                                <th>Autor</th>
                                <th>Splnené</th>
                            </tr>
                        </thead>
                        <tbody>
                        {% for achi in top_achievements_list_user %}
                            <tr>
                                <td><a href="{% url show_one_achievement achievement_id=achi.uuid %}">{{achi.name}}</a></td>
                                
                                {% if achi.points == 0 %}
                                    <td><span class="badge">Bez odmeny</span></td>
                                {% else %}
                                    <td><span class="badge badge-info">{{ achi.points }}</span>
					{% if achi.points == 1 %}bod
					{% elif achi.points >= 2 and achi.points <= 4 %}body
					{% else %}bodov
					{% endif %}
                                    </td>
                                {% endif %}
                                
                                <td><a href="{% url show_user user_id=achi.author %}">{{ achi.author }}</a></td>
                                <td><span class="badge">{{ achi.count }}</span> krát</td>
                            </tr>
                        {% endfor %}
                        <tbody>
                    </table>
                {% else %}
                    <p> Nie sú dostupné žiadne obľúbené používateľské achievementy. </p>
                {% endif %}
            </div>
    </div>
    
    
    <div class="page-header">
        <h3>Top používatelia</h3>
        <div>
	    {% if top_users_list %}
		<table class='table table-striped table-bordered'>
		    <thead>
			<tr>
			    <th>Používateľ</th>
			    <th>Počet bodov</th>
			    <th>Vytvorené</th>
			    <th>Splnené</th>
			</tr>
		    </thead>
		    <tbody>
		    {% for usr, countmade in top_users_list.iteritems %}
			<tr>
			    <td><a href="{% url show_user user_id=usr.user.username %}">{{usr.user.username}}</a></td>
			    
			    <td><span class="badge badge-info">{{ usr.user_points }}</span>
				{% if usr.user_points == 1 %}bod
				{% elif usr.user_points >= 2 and usr.user_points <= 4 %}body
				{% else %}bodov
				{% endif %}
			    </td>
			    <td><span class="badge">{{ countmade }}</span>
				{% if countmade == 1 %}achievement
				{% elif countmade >= 2 and countmade <= 4 %}achievementy
				{% else %}achievementov
				{% endif %}
			    </td>
			    
			    <td><span class="badge">{{ usr.countdone }}</span>
				{% if usr.countdone == 1 %}achievement
				{% elif usr.countdone >= 2 and usr.countdone <= 4 %}achievementy
				{% else %}achievementov
				{% endif %}
			    </td>
			</tr>
		    {% endfor %}
		    </tbody>
		</table>
	    {% else %}
		<p> Nie sú dostupní žiadni top používatelia. </p>
	    {% endif %}
        </div>
    </div>
    
    

{% endblock %}

